#ifndef __T30_HELIX_ENC_API_H__
#define __T30_HELIX_ENC_API_H__
#include <stdint.h>

typedef uint8_t  JZ_U8;
typedef uint16_t JZ_U16;
typedef uint32_t JZ_U32;
typedef int8_t   JZ_S8;
typedef int16_t  JZ_S16;
typedef int32_t  JZ_S32;
typedef float    JZ_FL;
typedef int      JZ_BL;
#if 0
typedef enum {
    CBR,
    VBR,
    SMART = 3
} VPU_RC_MODE_S_T30;

typedef enum {
    STILL      = 0,
    STILLTOMOVE= 1,
    MOVETOSTILL= 2,
    MOVE       = 3,
    SHARPMOVE  = 4,
} VPU_RC_SCENE_CONDIENT_S_T30;
#endif
typedef enum {
    NVBR,
    AVBR
} VPU_RC_VBR_MODE_S_T30;
typedef enum{
    QPG_CLOSE,
    QPG_CRP,
    QPG_SAS,
    QPG_SASM,
    QPG_MBRC
} VPU_RC_QPG_MODE_S_T30;
typedef enum {
    SMOOTH_STREAM,
    SMOOTH_QUALITY,
    BITRATE_ONLY
} VPU_RC_VIDEO_EFFECT_S_T30;

typedef enum {
    X264_STYPE_N1X       = 0,
    X264_STYPE_N2X       = 1,
    X264_STYPE_N4X       = 2,
    X264_STYPE_HN1_FALSE = 3,
    X264_STYPE_HN1_TRUE  = 4,
    X264_STYPE_H1M_FALSE = 5,
    X264_STYPE_H1M_TRUE  = 6
} VPU_RC_SKIP_TYPE_S_T30;

typedef enum {
    FS_KEY     = 0,
    FS_LBASE   = 1,
    FS_SBASE   = 2,
    FS_ENHANCE = 3
} VPU_RC_FRM_SKIP_TYPE_S_T30;

typedef struct jzVPU_ATTR_H264_CBR_S_T30 {
    JZ_U8                    u8Fps;
    JZ_U16                   u16Gop;
    JZ_U8                    u8StatTime;
    JZ_U32                   u32BitRate;
    JZ_U8                    u8FluctuateLevel;
    JZ_S8                    s8FirstFrmStartQp;
}VPU_ATTR_H264_CBR_S_T30;

typedef struct jzVPU_PARAM_H264_CBR_S_T30 {
    JZ_U8                    u8MaxQp;
    JZ_U8                    u8MinQp;
    JZ_U8                    u8FrmQpStep;               /* input  P and P frame qp step */
    JZ_U8                    u8GopQpStep;               /* input  P and I frame qp step */
    JZ_U8                    u8MaxReEncTimesPS;         /* input  max allowed reencode times per second */
    JZ_U8                    u8SuperFrmReencTimes;

    JZ_U32                   u32SuperIFrmBitsThr;
    JZ_U32                   u32SuperPFrmBitsThr;
    JZ_S8                    s8IPQpDlt;
    JZ_S8                    s8IQpBias;
    JZ_U8                    u8MaxIprop;
    JZ_U8                    u8MinIprop;

}VPU_PARAM_H264_CBR_S_T30;

typedef struct jzVPU_ATTR_H264_VBR_S_T30 {
    JZ_U8                    u8Fps;
    JZ_U16                   u16Gop;
    JZ_U8                    u8StatTime;
    JZ_U32                   u32MaxBitrate;
    JZ_U8                    u8FluctuateLevel;
    JZ_S8                    s8FirstFrmStartQp;
}VPU_ATTR_H264_VBR_S_T30;

typedef struct jzVPU_PARAM_H264_VBR_S_T30 {
    JZ_U8                    u8MaxQp;
    JZ_U8                    u8MinQp;
    JZ_U8                    u8MinIQp;
    JZ_U8                    u8FrmQpStep;               /* input  P and P frame qp step */
    JZ_U8                    u8GopQpStep;               /* input  P and I frame qp step */
    JZ_U8                    u8QualityLvl;
    JZ_U8                    u8MaxReEncTimesPS;         /* input  max allowed reencode times per second */
    JZ_U8                    u8SuperFrmReencTimes;
    JZ_U32                   u32SuperIFrmBitsThr;
    JZ_U32                   u32SuperPFrmBitsThr;
    JZ_U8                    u8ChangePos;
    JZ_U32                   u32MinbitRate;
    JZ_S8                    s8IPQpDlt;
    JZ_S8                    s8IQpBias;
    JZ_U8                    u8MaxIprop;
    JZ_U8                    u8MinIprop;

}VPU_PARAM_H264_VBR_S_T30;


typedef struct jzVPU_ATTR_H264_SMART_S_T30 {
    JZ_U8                    u8Fps;
    JZ_U16                   u16Gop;
    JZ_U8                    u8StatTime;
    JZ_U32                   u32MaxBitrate;
    JZ_U8                    u8FluctuateLevel;
    JZ_S8                    s8FirstFrmStartQp;
}VPU_ATTR_H264_SMART_S_T30;

typedef struct jzVPU_PARAM_H264_SMART_S_T30 {
    JZ_U8                    u8MaxQp;
    JZ_U8                    u8MinQp;
    JZ_U8                    u8MinIQp;
    JZ_U8                    u8FrmQpStep;               /* input  P and P frame qp step */
    JZ_U8                    u8GopQpStep;               /* input  P and I frame qp step */
    JZ_U8                    u8QualityLvl;
    JZ_U8                    u8MaxReEncTimesPS;         /* input  max allowed reencode times per second */
    JZ_U8                    u8SuperFrmReencTimes;
    JZ_U32                   u32SuperIFrmBitsThr;
    JZ_U32                   u32SuperPFrmBitsThr;
    JZ_U8                    u8ChangePos;
    JZ_U32                   u32MinbitRate;
    JZ_U8                    u8GopNum;
    JZ_S8                    s8IPQpDlt;
    JZ_S8                    s8IQpBias;
    JZ_U8                    u8MaxIprop;
    JZ_U8                    u8MinIprop;
}VPU_PARAM_H264_SMART_S_T30;


typedef struct jzVPU_RC_S_T30 {
    VPU_RC_MODE_S                rcMode;                    /* CBR, VBR, SMART */
    VPU_RC_VBR_MODE_S_T30        vbrMode;
    VPU_ATTR_H264_CBR_S_T30      attrH264Cbr;               /* CBR mode attribut parametr */
    VPU_ATTR_H264_VBR_S_T30      attrH264Vbr;               /* VBR mode attribut parametr */
    VPU_ATTR_H264_SMART_S_T30    attrH264Smart;             /* SMART mode attribute parameter */
    VPU_PARAM_H264_CBR_S_T30     paramH264Cbr;              /* CBR mode high parametr */
    VPU_PARAM_H264_VBR_S_T30     paramH264Vbr;              /* VBR mode high parametr */
    VPU_PARAM_H264_SMART_S_T30   paramH264Smart;            /* SMART mode high parametr */

    VPU_RC_QPG_MODE_S_T30        qpgMode;
    VPU_RC_SKIP_TYPE_S_T30       rcSkipType;                /* input  skip    type */
    VPU_RC_FRM_SKIP_TYPE_S_T30   frmSkipType;
    JZ_U8                    FrameType;
    JZ_U16                   MbWidth;                /* input  current frame size in width */
    JZ_U16                   MbHeight;               /* input  current frame size in height */
    JZ_U8                    u8CuRcEn;                  /* input  wither  open cu level rate control */
    JZ_U32                   ActualBits;               /* input  current frame actual encode bits */
    JZ_BL                    bIFrmReq;                  /* input  whether require I frame */
    JZ_BL                    bCrpEn;                    /* input  smooth area test enable by jmqi */
    JZ_BL                    bSasEn;                    /* input  smooth area test enable by zyzhao */
    JZ_BL                    bSasmEn;                   /* input  smooth area test enable by zyzhao */
    JZ_BL                    bRoiEn;                    /* input  roi test enable */
    JZ_BL                    bQpTblEn;                  /* input  qp table enable */
    JZ_BL                    bMbRcEn;                   /* input  mb rate control enable */
    double                   PredMad;                 /* input  previous frame mad */
    uint64_t                 u32FrmSse;                 /* input  previous frame sse */
    JZ_U32                   u32MbInterCnt;               /* input  previous frame inter count */
    JZ_U32                   u32MbInterMv;                /* input  previous frame sum of inter mv */
    VPU_RC_VIDEO_EFFECT_S_T30    videoEffect;               /* input  final video effect */
    //crp,sas
    JZ_U32                   u32CrpRgnc[8];
    JZ_U32                   u32SasCnt[3];
    JZ_S8                    crpMbQpOfst[8];
    JZ_S8                    sasMbQpOfst[7];
    JZ_U8                    FrameQP;                   /* output current frame qp */
    JZ_U8                    u8FrmSceCndt;              /* output current frame scene condidant */
    JZ_U32                   u32FrmTgtBs;               /* output current frame target bits */
    JZ_U8                    u8ChgRefEn;
    JZ_U8                    ChangeRef;
    void                     *RCptr0;
    void                     *RCptr1;
} VPU_RC_S_T30;

void eprc_default_set_t30(VPU_RC_S_T30 *rc);
void JZ_VPU_RC_VIDEO_CFG_T30(VPU_RC_S_T30 *rc);
void JZ_VPU_RC_FRAME_START_T30(VPU_RC_S_T30 *rc);
void JZ_VPU_RC_FRAME_END_T30(VPU_RC_S_T30 *rc);
int  JZ_VPU_RC_FRAME_REPEATE_JUDGE_T30(VPU_RC_S_T30 *rc);
void JZ_VPU_RC_FREE_T30(VPU_RC_S_T30 *rc);

#endif //__T30_HELIX_ENC_API_H__
